<script setup lang="ts">
import { useRoute } from "vue-router";
import { ArrowDown } from "@element-plus/icons-vue";

import { navList } from "../config";

const route = useRoute();
</script>

<template>
  <!-- pc -->
  <ul class="pcnav-container">
    <template v-for="nav in navList">
      <li>
        <router-link active-class="active" :to="nav.path">
          {{ nav.name }}</router-link
        >
      </li>
    </template>
  </ul>
  <!-- mobile -->
  <el-dropdown class="header-dropdwon" style="margin-right: 30px">
    <span class="el-dropdown-link">
      {{ route.name }}
      <el-icon><ArrowDown /></el-icon>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <template v-for="nav in navList">
          <el-dropdown-item>
            <router-link :to="nav.path"> {{ nav.name }}</router-link>
          </el-dropdown-item>
        </template>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<style scoped lang="less">
.pcnav-container {
  display: flex;
  font-size: 14px;
  li {
    width: 70px;
    a {
      display: inline-block;
      border-bottom: 2px solid transparent;
      margin-top: 2px;
      &:hover {
        border-bottom: 2px solid #1e80ff;
      }
    }
  }
}
.header-dropdwon {
  display: none;
  cursor: pointer;
}
</style>
